import type { Compiler } from "webpack";
import { BuildPrinter } from "../../common/hooks";
class CostWebpackPlugin {
  #hooks: BuildPrinter;
  constructor(name?: string) {
    this.#hooks = new BuildPrinter(name);
  }
  apply(compiler: Compiler) {
    this.#hooks.start();
    compiler.hooks.compile.tap("CostWebpackPlugin", () => {
      this.#hooks.loaded();
    });
    compiler.hooks.done.tap("CostWebpackPlugin", () => {
      this.#hooks.compiled();
    });
    compiler.hooks.afterDone.tap("CostWebpackPlugin", () => {
      this.#hooks.done();
    });
  }
}

export { CostWebpackPlugin };
